<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@include file="../base.jsp"%> 
<%
	String a1TemplateTableId = request.getParameter("a1TemplateTableId");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>客户查询</title>    
<link href="../css/main.css" rel="stylesheet" type="text/css" >

<link rel="stylesheet" type="text/css" href="../../js/jquery/easyui1.5/themes/bootstrap/easyui.css">
<link rel="stylesheet" type="text/css" href="../../js/jquery/easyui1.5/themes/icon.css">
<script type="text/javascript" src="../../js/jquery-1.8.0.min.js"></script>
<script src="../../js/jquery/easyui1.5/jquery.easyui.min.js"></script>
<script src="../../js/jquery/easyui1.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../js/jquery.select.js"></script>

<script type="text/javascript">

var datagrid={
    datagridId:"list",
    datagridUrl:"templateAjax_tableColumnListBySearch.action",
    datagridObj:{
        /*title:"查询列表",*/
        nowrap:true,
        autoRowHeight:false,
        fit:true,
        columns:[
            [
                {field:'columnName',title:'列名'},
                {field:'columnShowName',title:'列名显示名'},
                {field:'columnNameSql',title:'列Sql'},
                {field:'columnNameSqlSum',title:'列合计Sql'},
                {field:'isFrozenColumn',title:'是否冻结列'},
                {field:'needSum',title:'是否需要合计'},
                {field:'isHidden',title:'是否隐藏(主键)'},
                {field:'sort',title:'排序'}
            ]
        ],
        onRowContextMenu: onRowContextMenu,
        rownumbers:true,
		frozenColumns:[[
					]],
        toolbar:[
                   {
                     id:'addBtnId',
                     text:'添加',
                     iconCls:'icon-add',
                     handler:function(){
                    	 addColumn();
                     }
                   },
                   {
                       id:'refreshBtnId',
                       text:'刷新',
                       iconCls:'icon-reload',
                       handler:function(){
                    	   reLoadData();
                       }
                  }
                 ]
    },
    datagridProperty:{
    	recordDateStart:'创建日期(起)',
    	recordDateEnd:'创建日期(止)'
    },
    datagridPropertySort:{
        id:'默认属性'
    }/*,
    datagridPropertyMultiQuery:{
        enableStateId:'状态'
    }*/
};

//添加右击菜单内容
var terminalId;
var terminalNo;
function onRowContextMenu(e, rowIndex, rowData){
	e.preventDefault();
	var selected=$("#list").datagrid('getRows'); //获取所有行集合对象
	terminalId = selected[rowIndex].id; //index为当前右键行的索引，指向当前行对象
	terminalNo = selected[rowIndex].terminalNo; 
	$('#mm').menu('show', {
	    left:e.pageX,
	    top:e.pageY
	});       
}


//
function addColumn() { 
	$('#mydialogAdd').show(); 
	$('#mydialogAdd').dialog({
		modal:true, 
		buttons: [{ 
			text: '提交', 
			iconCls: 'icon-ok', 
			handler: function() { 
				$.ajax({
					type:"POST",
					url:"templateAjax_addA1TemplateColume.action",
					dataType:"json",
					data:{
						'a1TemplateTableId':$('#a1TemplateTableId').val(),
						'columnName':$('#columnName').val(),
						'columnShowName':$('#columnShowName').val(),
						'columnNameSql':$('#columnNameSql').val(),
						'columnNameSqlSum':$('#columnNameSqlSum').val(),
						'needSum':$('#needSum').val(),
						'isFrozenColumn':$('#isFrozenColumn').val(),
						'sort':$('#sort').val(),
						'isHidden':$('#isHidden').val()
					},
					success:function(msg){
						var msg = eval("("+msg+")"); 
						if(msg.responseCode==0){
							alert(msg.responseContent);
							return;
						}			
						if(confirm('操作成功\r\n是否刷新数据?')){
							reLoadData(); 
							$('#columnName').val('');
							$('#columnShowName').val('');
							$('#columnNameSql').val('');
							$('#columnNameSqlSum').val('');
							$('#needSum').val('');
							$('#isFrozenColumn').val('');
							$('#sort').val('');
							$('#isHidden').val('');
							$('#mydialogAdd').dialog("close");
						}	
						return;
					},
					error:function(er){
						alert('操作失败：请先确认是否授权访问该资源');
					}
				 });
			} 
		}, { 
			text: '取消', 
			iconCls: 'icon-cancel', 
			handler: function() { 
				$('#mydialogAdd').dialog("close");
			} 
		}] 
	}); 

} 

</script>
<style type="text/css">
	.west{
		width: 200px;
		padding: 3px;
		style="overflow-y:auto; 
		overflow-x:hidden;"
	}
	.center{
		padding: 3px;
	}
</style>
</head>

    
<body id="wrap" class="easyui-layout" style="margin: 2px;">
	<input type="hidden" id="a1TemplateTableId" name="a1TemplateTableId" value="<%=a1TemplateTableId%>"/>
	
	<div title="条件搜索" style="display: none;">
        <jsp:include page="../condition.jsp"></jsp:include>
		<script type="text/javascript">
			paramData['a1TemplateTableId']=$('#a1TemplateTableId').val();
			reLoadData();  
		</script>
	</div>
	<div region="center" class="center" >
         <table id="list" width="100%" ></table>
	</div>
	
	<!-- 右击菜单
	<div id="mm" class="easyui-menu" style="width:120px;">
	    <div onClick="showProductList()" data-options="iconCls:'icon-search'">查看产品列表</div>
	    <div onClick="bindRateToMerchantTerminal()" data-options="iconCls:'icon-add'">绑定费率</div>
	    <!-- <div class="menu-sep"></div> -->
	</div>
	 -->
	<!-- 添加对话框 -->
	<div id="mydialogAdd" style="display:none;padding:5px;width:500px; height: 300px" title="添加"> 
		<table class="table3" cellpadding="0" cellspacing="0" align="center" width="100%">
			<tr>
				<td>
					<span>列名:</span>
					<div>
						<input id="columnName" name="columnName" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>列名显示名:</span>
					<div>
						<input id="columnShowName" name="columnShowName" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>列Sql:</span>
					<div>
						<input id="columnNameSql" name="columnNameSql" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>列合计Sql:</span>
					<div>
						<input id="columnNameSqlSum" name="columnNameSqlSum" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>是否需要合计:</span>
					<div>
						<input id="needSum" name="needSum" size="30" class="easyui-validatebox" data-options="required:true"/>
						[1:true, 0:false]
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>是否冻结列:</span>
					<div>
						<input id="isFrozenColumn" name="isFrozenColumn" size="30" class="easyui-validatebox" data-options="required:true"/>
						[1:true, 0:false]
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>是否隐藏列:</span>
					<div>
						<input id="isHidden" name="isHidden" size="30" class="easyui-validatebox" data-options="required:true"/>
						[1:true, 0:false]
					</div>
				</td>
			</tr>
			<tr>
				<td>
					<span>排序:</span>
					<div>
						<input id="sort" name="sort" size="30" class="easyui-validatebox" data-options="required:true"/>
					</div>
				</td>
			</tr>
		</table>
	</div>
	
	
</body>
</html>